<?php

declare(strict_types=1);

namespace App\Request\User;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class ExchangeGiftRequest extends BaseCommonRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    protected array $scenes = [
        'query' => ['type'],// 查询积分
        'exchange' => ['type', 'exchange_num', 'channel', 'from', 'package', 'version_code'] // 兑换金币
    ];

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'query' => [
                'type' => 'required|in:1,2',
            ],
            'exchange' => [
                'type' => 'required|in:1,2',
                'exchange_num' => 'required|integer|gt:9',
                'channel' => 'required',
                'form' => 'required',
                'package' => 'required',
                'version_code' => 'required',
            ],
        ];
    }

    public function messages(): array
    {
        $language = Context::get('language');
        if ($language == 'zh-zn') {
            return [
                'type.required' => '操作不能为空',
                'type.in' => '操作只能为1,2',
                'exchange_num.required' => '兑换数量不能为空',
                'exchange_num.integer' => '兑换数量只能为整数',
                'exchange_num.gt' => '兑换数量必须大于9',
                'channel.required' => '渠道不能为空',
                'form.required' => '来源不能为空',
                'package.required' => '包名不能为空',
                'version_code.required' => '版本号不能为空',

            ];
        } elseif ($language == 'zh-hk') {
            return [
                'type.required' => '操作不得為空',
                'type.in' => '操作只能為1,2',
                'exchange_num.required' => '兌換數量不得為空',
                'exchange_num.integer' => '兌換數量只能為整數',
                'exchange_num.gt' => '兌換數量必須大於10',
                'channel.required' => '渠道不得為空',
                'form.required' => '來源不得為空',
                'package.required' => '包名不得為空',
                'version_code.required' => '版本號不得為空',
            ];
        } else {
            return [
                'type.required' => 'type cannot be empty',
                'type.in' => 'Action can only be 1,2',
                'exchange_num.required' => 'exchange_num cannot be empty',
                'exchange_num.integer' => 'exchange_num can only be integer',
                'exchange_num.gt' => 'exchange_num must be greater than 9',
                'channel.required' => 'channel cannot be empty',
                'form.required' => 'form cannot be empty',
                'package.required' => 'package cannot be empty',
                'version_code.required' => 'version_code cannot be empty',
            ];
        }
    }

}
